package person.bing.fbcloud.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: mengfanbing
 * @date: 2020/8/31 9:31
 */
public class Q841 {
    public static void main(String[] args) {
        boolean[] temp = new boolean[10];
        System.out.println(temp[1]);
    }
    static boolean[] temp;
    static int num;
    public static boolean canVisitAllRooms(List<List<Integer>> rooms) {
        int size = rooms.size();
        temp = new boolean[size];
        util(rooms,0);
        return size == num;
    }
    public static void util(List<List<Integer>> rooms,Integer index){
        temp[index] = true;
        num++;
        for (Integer room:rooms.get(index)){
            if (!temp[room]){
                util(rooms,room);
            }
        }
    }
}
